import Vue from 'vue'

import Cookies from 'js-cookie'
import i18n from './lange'
// import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import ZcsdSys from 'zcsd-core'
// import ZcsdSys from 'zcsd-core/src/index'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import config from './config'
import service from './utils/request'
import SelectCheckBox from '@/components/SelectCheckBox'
// import permission from './directive/permission'

import './icons' // icon

import { getDicts } from '@/api/system'
// import { getConfigKey } from '@/api/system/config'
import {
  resetForm,
  validNumberRangeInput,
  getAttrs,
  selectDictLabel,
  addDateRange,
  getCurrentPage,
  getDateByMinutes } from '@/utils/costum'

import { deepClone } from '@/utils'

import Pagination from '@/components/Pagination'

import * as filters from './filters' // global filters

import 'remixicon/fonts/remixicon.css'
// Vue.use(ElementUI)
// import './mock/index.js'
Vue.use(ZcsdSys, {
  router,
  service,
  config,
  store,
  i18n: (key, value) => i18n.t(key, value),
  size: Cookies.get('size') || 'medium' // set element-ui default size
})
// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
Vue.prototype.getDicts = getDicts
// Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.resetForm = resetForm
Vue.prototype.validNumberRangeInput = validNumberRangeInput
Vue.prototype.getAttrs = getAttrs
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.addDateRange = addDateRange
Vue.prototype.deepClone = deepClone
Vue.prototype.getCurrentPage = getCurrentPage
Vue.prototype.getDateByMinutes = getDateByMinutes

Vue.prototype.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: 'success' })
}
Vue.prototype.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: 'error' })
}
Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg)
}

Vue.component('Pagination', Pagination)
Vue.component('SelectCheckBox', SelectCheckBox)

Vue.config.productionTip = false

// eslint-disable-next-line
const app = new Vue({
  el: '#app',
  i18n,
  router,
  store,
  render: h => h(App)
})
